﻿@model ATTools.ViewModels.VoiceCommandsAdminIndexViewModel
@using ATTools.ViewModels;
@using ATTools.Models;
@using Orchard.Utility.Extensions;
@{
    Layout.Title = T("Manage Voice Commands");
}
<p>@T("This page lets you manage the available voice commands, that will be accessible by users, when the 'Voice Command Widget' is inserted somewhere on your website.")</p>
<br/>
@using(Html.BeginFormAntiForgeryPost()) {
    <fieldset class="bulk-actions">
        <label for="publishActions">@T("Actions:")</label>
        <select id="publishActions" name="@Html.NameOf(m => m.BulkAction)">
            @Html.SelectOption(Model.BulkAction, VoiceCommandAdminIndexBulkAction.None, T("Choose action...").ToString())
            @Html.SelectOption(Model.BulkAction, VoiceCommandAdminIndexBulkAction.Delete, T("Remove").ToString())
        </select>
        <button type="submit"name="submit.BulkEdit" value="@T("Apply")">@T("Apply")</button>
    </fieldset>
    <fieldset>
        <table class="items" summary="@T("This is a table of the voice commands in your application")" >
            <colgroup>
                <col id="Name" />
                <col id="Email" />
                <col id="Edit" />
            </colgroup>
            <thead>
                    <th scope="col">&nbsp;&darr;</th>
                    <th scope="col">@T("Activation string")</th>
                    <th scope="col">@T("Type of execution")</th>
                    <th scope="col">@T("Execution data")</th>
                    <th scope="col"></th>
            </thead>
            @{var voiceCommandIndex = 0;}
            @foreach (var voiceCommandEntry in Model.VoiceCommands)
            { 
            <tr>
                <td>
                    <input type="hidden" value="@Model.VoiceCommands[voiceCommandIndex].VoiceCommand.Id" name="@Html.NameOf(m => m.VoiceCommands[voiceCommandIndex].VoiceCommand.Id)"/>
                    <input type="checkbox" value="true" name="@Html.NameOf(m => m.VoiceCommands[voiceCommandIndex].IsChecked)"/>
                </td>
                <td>
                    @Html.ActionLink(voiceCommandEntry.VoiceCommand.Description, "EditVoiceCommand", new { id = voiceCommandEntry.VoiceCommand.Id })
                </td>
                <td>
                    @Html.ActionLink(((CommandType)voiceCommandEntry.VoiceCommand.CommandType).ToString(), "EditVoiceCommand", new { id = voiceCommandEntry.VoiceCommand.Id })
                </td>
                <td>
                    @Html.ActionLink(voiceCommandEntry.VoiceCommand.CommandData, "EditVoiceCommand", new {id = voiceCommandEntry.VoiceCommand.Id})
                </td>
                <td>
                    @Html.ActionLink(T("Edit").ToString(), "EditVoiceCommand", new { id = voiceCommandEntry.VoiceCommand.Id }) @T(" | ")
                    <a href="@Url.Action("RemoveVoiceCommand", new { voiceCommandEntry.VoiceCommand.Id })" itemprop="RemoveUrl UnsafeUrl">@T("Remove")</a>
                </td>
            </tr>
            voiceCommandIndex++;
            }
        </table>
    </fieldset>
}
